<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.filter.TekunaFilter');


	/**
	 * This filter converts incoming data into a boolean value.
	 */

	class BooleanFilter implements TekunaFilter {


		/**
		 * The input is casted to boolean. Additionally it is checked
		 * to be the string 'false' that is considered as the boolean
		 * false value, too.
		 *
		 * @param mixed $mInput the input
		 * @return boolean
		 */

		public function filter($mInput) {

 			// additionally to PHP's boolean typecasts, consider
 			// the string 'false' as the boolean false value
 			if (strtolower(trim($mInput)) === 'false') {

 				return false;
 			}

			return (boolean) $mInput;
		}
	}
